/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.atomcorp.controlador;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import vista.SistemaFacturacion;


/**
 *
 * @author manu
 */
public class LoginControlador{
    @FXML private TextField txtUsuario;
    @FXML private PasswordField txtPassword;
    @FXML private Label msgUsuario;
    @FXML private Label msgPassword;
    @FXML private Label msgError;
    
//    private SistemaRecetas aplicacion;
    
//   public void setApp(SistemaRecetas application){
//        this.aplicacion = application;
//    }
    
    @FXML
    protected void btnLogin(ActionEvent event){
        if("".equals(txtUsuario.getText())){
            msgUsuario.setText("El Usuario es requerido!");
        }else{
             msgUsuario.setText("");
        }
        if("".equals(txtPassword.getText())){
            msgPassword.setText("La contraseña es requerido!");
        }else{
            msgPassword.setText("");
        }
        if(!"".equals(txtUsuario.getText()) && !"".equals(txtPassword.getText())){
            if(!SistemaFacturacion.getInstance().userLogging(txtUsuario.getText(), txtPassword.getText())){
                msgError.setText("Usuario/Contraseña son incorrectas");
                System.out.println("Error de ingreso");
            }else{
                msgError.setText("");
            }
        }
        
    }
    
}
